Repository navigation
Start a program or working folder past Windows' path limit by its 8.3 short name - #125
Merged
Merged
Conversation
…t name Windows refuses a program path of 260 characters or more and a working folder of 259 or more, on both start paths and with long paths enabled. When a start fails with one of those, the kit tries once more with their short names; without short names, or if that fails too, the first error is reported as before. Harness section BO covers both start paths.
…if the short-name lookup throws Without an 8.3 short name to try, a start that failed for a program path of 260 characters or more, or a working folder of 259 or more, now adds a sentence saying the length is why. GetShortPath returns null instead of throwing on characters .NET Framework refuses. Section BO's error checks look for the retry's short names, not any '~', since TEMP is itself a short path on some machines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong: Windows won't start a program by a path of 260 characters or more, or in a working folder of 259 or more (it adds a backslash). That holds even with long paths enabled and in the
\\?\form, on both start paths (measured on Windows PowerShell 5.1 and PowerShell 7). So these starts failed with "The filename or extension is too long", "The directory name is invalid", or, for a plain program path on PowerShell 7, "The system cannot find the file specified". Windows PowerShell 5.1's own& $exeseems to start such a program, but only through its fallback for files it can't start: shell32'sFindExecutablereturns the program by its 8.3 short name, and PowerShell runs that with the long path added in front of the arguments, so the program gets a wrong argument list.What changed:
Start-PkProcessCoretries once more with their 8.3 short names, fromGetShortPathNameWwith the\\?\prefix. That covers the batch, the dispatcher,Start-PkProcessandInvoke-PkProcessWithTimeout. The program's arguments are passed as given.PkChildProcessJob.GetShortPath. The README's Limits line is updated.How it was tested: new harness section BO, run on both start paths (
CreatedInJobandProcess.Start), in a 358-character folder under%TEMP%with a copy ofcmd.exe:Invoke-PkProcessWithTimeout.The cases that need short names skip on a volume without them.
Before the fix (main's kit, this branch's harness,
-Section BO): 11 failed, 6 passed, on both 5.1 and 7. The six that pass are setup and the error cases that need no new message. After: all 17 of A and BO pass on both. Full harness on this branch: all 793 assertions pass on Windows PowerShell 5.1 and on PowerShell 7.